package com.naiterui.ehp.bs.emr.utils.enums;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 病情周期描述
 */
public enum DiseaseCycleEnum {

    /**
     * 病情周期描述
     */
    WEEK(1, "一周内", "持续几天"),
    MONTH(2, "一月内","持续近月"),
    LT_SIX_MONTH(3, "半年内", "持续数月"),
    GT_SIX_MONTH(4, "大于半年", "持续半年以上");

    /**
     * 编码
     */
    private int code;

    /**
     * 标签
     */
    private String label;

    /**
     * 描述
     */
    private String description;

    public int getCode() {
        return code;
    }

    public String getLabel() {
        return label;
    }

    public String getDescription() {
        return description;
    }

    DiseaseCycleEnum(int code, String label, String description) {
        this.code = code;
        this.label = label;
        this.description = description;
    }

    public static List<DiseaseCycle> toList(){

        return Arrays.stream(values()).map(s -> DiseaseCycle.builder()
                .code(s.getCode())
                .description(s.getDescription())
                .label(s.getLabel())
                .build()).collect(Collectors.toList());
    }

    public static DiseaseCycle get(Integer code){

        return Arrays.stream(values()).filter(s -> s.code == code).map(s -> DiseaseCycle.builder()
                .code(s.getCode())
                .description(s.getDescription())
                .label(s.getLabel())
                .build()).findFirst().orElseGet(null);
    }

}
